home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / nfsmount / RCS / nfsName.c,v < prev    next >
Text File  |  1991-10-20  |  50KB  |  1,840 lines

  1. head     1.18;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.18
  10. date     91.09.24.11.47.50;  author mottsmth;  state Exp;
  11. branches ;
  12. next     1.17;
  13.  
  14. 1.17
  15. date     91.09.10.19.24.58;  author mottsmth;  state Exp;
  16. branches ;
  17. next     1.16;
  18.  
  19. 1.16
  20. date     91.06.07.16.24.24;  author mottsmth;  state Exp;
  21. branches ;
  22. next     1.15;
  23.  
  24. 1.15
  25. date     91.03.23.19.20.08;  author mottsmth;  state Exp;
  26. branches ;
  27. next     1.14;
  28.  
  29. 1.14
  30. date     91.03.23.18.42.58;  author mottsmth;  state Exp;
  31. branches ;
  32. next     1.13;
  33.  
  34. 1.13
  35. date     91.03.23.18.40.25;  author mottsmth;  state Exp;
  36. branches ;
  37. next     1.12;
  38.  
  39. 1.12
  40. date     90.01.25.17.19.32;  author brent;  state Exp;
  41. branches ;
  42. next     1.11;
  43.  
  44. 1.11
  45. date     89.10.10.13.17.19;  author douglis;  state Exp;
  46. branches ;
  47. next     1.10;
  48.  
  49. 1.10
  50. date     89.09.12.14.32.08;  author brent;  state Exp;
  51. branches ;
  52. next     1.9;
  53.  
  54. 1.9
  55. date     89.06.30.10.29.31;  author brent;  state Exp;
  56. branches ;
  57. next     1.8;
  58.  
  59. 1.8
  60. date     89.06.16.08.50.54;  author brent;  state Exp;
  61. branches ;
  62. next     1.7;
  63.  
  64. 1.7
  65. date     89.05.31.15.22.27;  author brent;  state Exp;
  66. branches ;
  67. next     1.6;
  68.  
  69. 1.6
  70. date     89.02.02.16.35.29;  author brent;  state Exp;
  71. branches ;
  72. next     1.5;
  73.  
  74. 1.5
  75. date     89.02.02.15.04.30;  author brent;  state Exp;
  76. branches ;
  77. next     1.4;
  78.  
  79. 1.4
  80. date     89.01.19.10.11.21;  author brent;  state Exp;
  81. branches ;
  82. next     1.3;
  83.  
  84. 1.3
  85. date     88.11.14.15.14.54;  author brent;  state Exp;
  86. branches ;
  87. next     1.2;
  88.  
  89. 1.2
  90. date     88.11.11.11.33.18;  author brent;  state Exp;
  91. branches ;
  92. next     1.1;
  93.  
  94. 1.1
  95. date     88.11.02.12.44.26;  author brent;  state Exp;
  96. branches ;
  97. next     ;
  98.  
  99.  
  100. desc
  101. @NFS naming operations
  102. @
  103.  
  104.  
  105. 1.18
  106. log
  107. @Check for NIL ptr from Pfs_OpenConnection before relying on
  108. it for the IOCTL.
  109. @
  110. text
  111. @/*
  112.  * nfsName.c --
  113.  * 
  114.  *    Procedures that interface to a remote NFS filesystem.  The procedures
  115.  *    here are called via the Pfs/Pdev library in response to naming requests
  116.  *    from the Sprite kernel about files in an NFS filesystem.
  117.  *
  118.  * Copyright 1988 Regents of the University of California
  119.  * Permission to use, copy, modify, and distribute this
  120.  * software and its documentation for any purpose and without
  121.  * fee is hereby granted, provided that the above copyright
  122.  * notice appear in all copies.  The University of California
  123.  * makes no representations about the suitability of this
  124.  * software for any purpose.  It is provided "as is" without
  125.  * express or implied warranty.
  126.  */
  127. #ifndef lint
  128. static char rcsid[] = "$Header: /sprite/src/cmds/nfsmount/RCS/nfsName.c,v 1.17 91/09/10 19:24:58 mottsmth Exp Locker: mottsmth $ SPRITE (Berkeley)";
  129. #endif not lint
  130.  
  131. #include "stdio.h"
  132.  
  133. #include "nfs.h"
  134. #include "sys/stat.h"
  135.  
  136. int nfsToSpriteFileType[] = {
  137.     FS_PSEUDO_DEV,        /* NFNON */
  138.     FS_FILE,            /* NFREG */
  139.     FS_DIRECTORY,        /* NFDIR */
  140.     FS_DEVICE,            /* NFBLK */
  141.     FS_DEVICE,            /* NFCHR */
  142.     FS_SYMBOLIC_LINK,        /* NFLNK */
  143. };
  144. int spriteToNfsModeType[] = {
  145.     S_IFREG,     /* FS_FILE */
  146.     S_IFDIR,    /* FS_DIRECTORY */
  147.     S_IFLNK,    /* FS_SYMBOLIC_LINK */
  148.     S_IFLNK,    /* FS_REMOTE_LINK */
  149.     S_IFCHR,    /* FS_DEVICE */
  150.     0,        /* FS_REMOTE_DEVICE - not used by Sprite */
  151.     0,        /* FS_LOCAL_PIPE - never seen by open */
  152.     S_IFIFO,    /* FS_NAMED_PIPE */
  153.     S_IFSOCK,    /* FS_PSEUDO_DEVICE */
  154.     S_IFLNK,    /* FS_PSEUDO_FS */
  155.     0,        /* FS_XTRA_FILE - used to test new Sprite types */
  156. };
  157.  
  158. /*
  159.  * Open file table.  A simple array of pointers to nfs_fh that
  160.  * is used to map between a Fs_FileID we give the Sprite kernel
  161.  * each time an NFS file is opened.  The minor field of the Sprite
  162.  * fileID is used as an index into this array of pointers to NFS handles.
  163.  */
  164. NfsOpenFile **nfsFileTable = (NfsOpenFile **)NULL;
  165. NfsOpenFile **nextFreeSlot = (NfsOpenFile **)NULL;
  166. int nfsFileTableSize = 0;
  167.  
  168. /*
  169.  * The following macro is used to map from a Sprite file ID to an NFS handle.
  170.  * This is used to interpret the prefixID passed to us on lookup operations.
  171.  * The Sprite kernel passes us a completly zero'd fileID for
  172.  * names that start at our root.  Otherwise it passes us the
  173.  * fileID we gave it when the process opened its current directory.
  174.  */
  175. #define PrefixIDToHandle(prefixID) \
  176.     ( (prefixID.type == TYPE_ROOT) ? (NfsOpenFile *)NULL : \
  177.     ((nfsFileTable == (NfsOpenFile **)NULL) ? (NfsOpenFile *)NULL : \
  178.         nfsFileTable[prefixID.minor] ) )
  179.  
  180. /*
  181.  * The set of callback procedures given to Pfs_Open.  These define the
  182.  * procedures called in response to pseudo-filesystem naming operations.
  183.  */
  184. Pfs_CallBacks nfsNameService= {
  185.     NfsOpen,            /* PFS_OPEN */
  186.     NfsGetAttrPath,        /* PFS_GET_ATTR */
  187.     NfsSetAttrPath,        /* PFS_SET_ATTR */
  188.     NfsMakeDevice,        /* PFS_MAKE_DEVICE */
  189.     NfsMakeDir,            /* PFS_MAKE_DIR */
  190.     NfsRemove,            /* PFS_REMOVE */
  191.     NfsRemoveDir,        /* PFS_REMOVE_DIR */
  192.     NfsRename,            /* PFS_RENAME */
  193.     NfsHardLink,        /* PFS_HARD_LINK */
  194.     NfsSymLink,            /* PFS_SYM_LINK */
  195.     NfsDomainInfo,         /* PFS_DOMAIN_INFO */
  196. };
  197.  
  198. void NfsSetupAuth();
  199.  
  200.  
  201. /*
  202.  *----------------------------------------------------------------------
  203.  *
  204.  * Nfs_InitClient --
  205.  *
  206.  *    Set up the CLIENT data structure needed to do SUN RPC to the
  207.  *    NFS server running on a particular host.
  208.  * 
  209.  * Results:
  210.  *    None.
  211.  *
  212.  * Side effects:
  213.  *    Calls clnt_create which sets up sockets and other related state.
  214.  *
  215.  *----------------------------------------------------------------------
  216.  */
  217. CLIENT *
  218. Nfs_InitClient(host)
  219.     char *host;
  220. {
  221.     register CLIENT *clnt;
  222.     VoidPtr voidArg;
  223.     VoidPtr voidRes;
  224.     int retryCnt = -1; /* infinite retries */
  225.  
  226.     clnt = clnt_create(host, NFS_PROGRAM, NFS_VERSION, "udp");
  227.     if (clnt == (CLIENT *)NULL) {
  228.     clnt_pcreateerror(host);
  229.     } else {
  230.     clnt->cl_auth = authunix_create_default();
  231.     if (!clnt_control(clnt, CLSET_RETRY_COUNT, &retryCnt)) {
  232.         clnt_perror(clnt, "clnt_control");
  233.     } else {
  234.         voidRes = nfsproc_null_2(&voidArg, clnt);
  235.         if (voidRes == (VoidPtr)NULL) {
  236.         clnt_perror(clnt, "nfsproc_null_2");
  237.         } else if (pdev_Trace) {
  238.         printf("Null RPC to NFS service at %s succeeded\n", host);
  239.         }
  240.     }
  241.     }
  242.     return(clnt);
  243. }
  244.  
  245. /*
  246.  *----------------------------------------------------------------------
  247.  *
  248.  * NfsProbe --
  249.  *
  250.  *    Called to test NFS access.  This dos a stat of the root of the
  251.  *    NFS system we have mounted.  The stat information is returned
  252.  *    so the pseudo-file-system server can properly establish the
  253.  *    user-visible fileID of the root.
  254.  * 
  255.  * Results:
  256.  *    1 if probe succeeded, 0 otherwise.
  257.  *
  258.  * Side effects:
  259.  *    Fills in the NFS attributes of the root directory.
  260.  *
  261.  *----------------------------------------------------------------------
  262.  */
  263.  
  264. int
  265. NfsProbe(nfsPtr, print, nfsAttrPtr)
  266.     NfsState *nfsPtr;        /* Top level state for NFS connection */
  267.     int print;            /* 1 to print out attributes */
  268.     attrstat *nfsAttrPtr;    /* NFS attributes of root */
  269. {
  270.  
  271.     if (clnt_call(nfsPtr->nfsClnt, NFSPROC_GETATTR, xdr_nfs_fh,
  272.         nfsPtr->mountHandle,
  273.         xdr_attrstat, nfsAttrPtr, nfsTimeout) != RPC_SUCCESS) {
  274.     clnt_perror(nfsPtr->nfsClnt, "NFSPROC_GETATTR");
  275.     return(0);
  276.     } else if (nfsAttrPtr->status != NFS_OK) {
  277.     printf("NfsProbe: Get attributes status %d\n", nfsAttrPtr->status);
  278.     return(0);
  279.     } else if (print) {
  280.     printf("Attributes of %s:%s\n", nfsPtr->host, nfsPtr->nfsName);
  281.     printf("\tFileID %x FS_ID %x\n",
  282.         nfsAttrPtr->attrstat_u.attributes.fileid,
  283.         nfsAttrPtr->attrstat_u.attributes.fsid);
  284.     printf("\tType %d mode 0%o links %d size %d\n",
  285.         nfsAttrPtr->attrstat_u.attributes.type,
  286.         nfsAttrPtr->attrstat_u.attributes.mode,
  287.         nfsAttrPtr->attrstat_u.attributes.nlink,
  288.         nfsAttrPtr->attrstat_u.attributes.size);
  289.     }
  290.     return(1);
  291. }
  292.  
  293. /*
  294.  *----------------------------------------------------------------------
  295.  *
  296.  * NfsOpen --
  297.  *
  298.  *    Called to open a file in the NFS system.  This does the open
  299.  *    with the NFS server and then opens a new pseudo-device connection
  300.  *    that will be used for all further operatiosn on the NFS file.
  301.  * 
  302.  * Results:
  303.  *    None.
  304.  *
  305.  * Side effects:
  306.  *    Calls clnt_create which sets up sockets and other related state.
  307.  *
  308.  *----------------------------------------------------------------------
  309.  */
  310. int
  311. NfsOpen(clientData, name, openArgsPtr, redirectInfoPtr)
  312.     ClientData clientData;        /* Ref. to NfsState */
  313.     char *name;                /* Pathname to open */
  314.     register Fs_OpenArgs *openArgsPtr;    /* Bundled arguments */
  315.     Fs_RedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  316. {
  317.     NfsState *nfsPtr = (NfsState *)clientData;
  318.     NfsOpenFile *cwdFilePtr;
  319.     Pdev_Stream *streamPtr;
  320.     diropres longDirResults;
  321.     diropokres *dirResultsPtr = &longDirResults.diropres_u.diropres;
  322.     createargs createArgs;
  323.     diropargs *wherePtr = &createArgs.where;
  324.     int status;
  325.     char component[NFS_MAXNAMLEN];
  326.     int created = 0;
  327.     int writeBehind = nfs_PdevWriteBehind;
  328.  
  329.     wherePtr->name = component;
  330.     cwdFilePtr = PrefixIDToHandle(openArgsPtr->prefixID);
  331.     NfsSetupAuth(nfsPtr, cwdFilePtr, &openArgsPtr->id);
  332.     status = NfsLookup(nfsPtr, cwdFilePtr, name, openArgsPtr->useFlags,
  333.                dirResultsPtr, &wherePtr, redirectInfoPtr);
  334.     if (status == NFSERR_NOENT && wherePtr != (diropargs *)NULL &&
  335.         (openArgsPtr->useFlags & FS_CREATE)) {
  336.     /*
  337.      * We need to create the file.  NfsLookup has set up createArgs.where
  338.      * to have the handle on the parent and the component to create.
  339.      */
  340.     register sattr *sattrPtr = &createArgs.attributes;
  341.  
  342.     sattrPtr->mode = openArgsPtr->permissions & 07777;
  343.     if (openArgsPtr->type >= 0 && openArgsPtr->type <= FS_XTRA_FILE) {
  344.         sattrPtr->mode |= spriteToNfsModeType[openArgsPtr->type];
  345.     } else {
  346.         printf("Open(\"%s\") bad type %d\n", name, openArgsPtr->type);
  347.         return(GEN_INVALID_ARG);
  348.     }
  349.     sattrPtr->uid = openArgsPtr->id.user;
  350.     sattrPtr->gid = -1;
  351.     sattrPtr->size = 0;
  352.     sattrPtr->atime.seconds = -1;
  353.     sattrPtr->atime.useconds = -1;
  354.     sattrPtr->mtime.seconds = -1;
  355.     sattrPtr->mtime.useconds = -1;
  356.     if (clnt_call(nfsPtr->nfsClnt, NFSPROC_CREATE, xdr_createargs,
  357.         &createArgs, xdr_diropres, &longDirResults, nfsTimeout)
  358.             != RPC_SUCCESS) {
  359.         clnt_perror(nfsPtr->nfsClnt, "NFSPROC_CREATE");
  360.         return(FAILURE);
  361.     }
  362.     status = longDirResults.status;
  363.     created = 1;
  364.     }
  365.     if (status != NFS_OK) {
  366.     status = NfsStatusMap(status);
  367.     } else {
  368.     register Fs_FileID *fileIDPtr;
  369.     register int full = 0;
  370.     /*
  371.      * We've got a good handle on the NFS file.  Time to do our own
  372.      * permission checking cause the NFS server is pretty lame.
  373.      */
  374.     status = CheckPermissions(&dirResultsPtr->attributes, created,
  375.           openArgsPtr->useFlags, &openArgsPtr->id, openArgsPtr->type);
  376.     if (status != SUCCESS) {
  377.         return(status);
  378.     }
  379.     /* 
  380.      * Save our file handle in an array indexed by part of the Fs_FileID
  381.      * we'll give to the Sprite kernel and to the pdev callback library.
  382.      * This will let us get back to the handle from prefixID's in open
  383.      * arguments, and from the client data passed to us from the callback
  384.      * library.
  385.      */
  386.     if (nfsFileTable == (NfsOpenFile **)NULL) {
  387.         /*
  388.          * Allocate and initialize the table.  It might grow later.
  389.          */
  390.         nfsFileTable = (NfsOpenFile **)malloc(64 * sizeof(NfsOpenFile *));
  391.         bzero((char *)nfsFileTable, 64 * sizeof(NfsOpenFile *));
  392.         nextFreeSlot = &nfsFileTable[0];
  393.         nfsFileTableSize = 64;
  394.     }
  395.     while (*nextFreeSlot != (NfsOpenFile *)NULL) {
  396.         nextFreeSlot++;
  397.         if (nextFreeSlot >= &nfsFileTable[nfsFileTableSize]) {
  398.         if (!full){
  399.             nextFreeSlot = &nfsFileTable[0];
  400.             full = 1;
  401.         } else {
  402.             /*
  403.              * Grow the table.
  404.              */
  405.             register NfsOpenFile **newTable =
  406.                 (NfsOpenFile **)malloc(nfsFileTableSize * 2 *
  407.                           sizeof(NfsOpenFile *));
  408.             bcopy((char *)nfsFileTable, (char *)newTable,
  409.                 nfsFileTableSize * sizeof(NfsOpenFile *));
  410.             bzero((char *)&newTable[nfsFileTableSize],
  411.                 nfsFileTableSize * sizeof(NfsOpenFile *));
  412.             free((char *)nfsFileTable);
  413.             nfsFileTable = newTable;
  414.             nextFreeSlot = &nfsFileTable[nfsFileTableSize];
  415.             nfsFileTableSize *= 2;
  416.          }
  417.          }
  418.      }
  419.      /*
  420.       * Save the NFS handle and the UNIX authentication of this user.
  421.       */
  422.      *nextFreeSlot = (NfsOpenFile *)malloc(sizeof(NfsOpenFile));
  423.      (*nextFreeSlot)->handlePtr = (nfs_fh *)malloc(sizeof(nfs_fh));
  424.      bcopy((char *)&dirResultsPtr->file,
  425.            (char *)(*nextFreeSlot)->handlePtr, NFS_FHSIZE);
  426.      {
  427.          register int numGroups;
  428.          numGroups = (openArgsPtr->id.numGroupIDs <= NGRPS) ?
  429.                  openArgsPtr->id.numGroupIDs : NGRPS ;
  430.          (*nextFreeSlot)->authPtr = authunix_create(myhostname,
  431.              openArgsPtr->id.user, openArgsPtr->id.group[0],
  432.              numGroups, openArgsPtr->id.group);
  433.     }
  434.      (*nextFreeSlot)->openFlags = openArgsPtr->useFlags;
  435.      /*
  436.       * Tell the Sprite kernel to set up a pseudo-device connection
  437.       * over which we'll see all future operations on the NFS file.
  438.       * The fileID we give here will come back to us if this open is
  439.       * for a chdir(); the fileID will be passed as the prefixID in
  440.       * the openArgs.  We set the type in order to differentiate
  441.       * it from the type of zero used for the fileID of our root.
  442.       */
  443.      fileIDPtr = (Fs_FileID *)malloc(sizeof(Fs_FileID));
  444.      fileIDPtr->minor = nextFreeSlot - nfsFileTable;
  445.      fileIDPtr->major = 0;
  446.      fileIDPtr->serverID = (int)nfsPtr;
  447.      switch(dirResultsPtr->attributes.type) {
  448.          case NFDIR:
  449.          fileIDPtr->type = TYPE_DIRECTORY;
  450.          break;
  451.          case NFLNK:
  452.          fileIDPtr->type = TYPE_SYMLINK;
  453.          break;
  454.          default:
  455.          fileIDPtr->type = TYPE_FILE;
  456.          writeBehind = 1;
  457.          break;
  458.      }
  459.      streamPtr = Pfs_OpenConnection(nfsPtr->pfsToken, fileIDPtr,
  460.              (16 * 1024) + 128,    /* request buffer size */
  461.              0, NULL,        /* no read buffer */
  462.              FS_READABLE | FS_WRITABLE, &nfsFileService);
  463.      /*
  464.       * Enable write-behind.  We'd like to let a writer overlap its writes.
  465.       * The request buffer is large enough for 2 8K block writes.  Using
  466.       * write-behind increases the write bandwidth from 9k/sec to 40k/sec.
  467.       */
  468.      if (streamPtr != (Pdev_Stream *)NULL) {
  469.          if (Fs_IOControl(streamPtr->streamID, IOC_PDEV_WRITE_BEHIND,
  470.                   sizeof(int), &writeBehind, 0, NULL) != 0) {
  471.          fprintf(stderr, "IOC_PDEV_WRITE_BEHIND failed\n");
  472.          }
  473.          streamPtr->clientData = (ClientData)fileIDPtr;
  474.      } else {
  475.          status = EINVAL;
  476.      }
  477.      }
  478.     return(status);
  479. }
  480.  
  481. /*
  482.  *----------------------------------------------------------------------
  483.  *
  484.  * NfsSetupAuth --
  485.  *
  486.  *    This procedure initializes the authentication information for
  487.  *    the NFS client structure.  It uses the AUTH * of the open
  488.  *    NFS file if possible.  For absolute pathnames, however, this
  489.  *    hasn't been setup yet so we do it here.
  490.  * 
  491.  * Results:
  492.  *    None.
  493.  *
  494.  * Side effects:
  495.  *    For absolute paths we create an AUTH structure that won't get free'd.
  496.  *   
  497.  *      True; it wasn't being freed, and at 500 bytes a pop it was
  498.  *      consuming major heap space. I added oldAuth to remember the pointer
  499.  *      and free it next time we come through here. JMS.
  500.  *      
  501.  *----------------------------------------------------------------------
  502.  */
  503. void
  504. NfsSetupAuth(nfsPtr, cwdFilePtr, idPtr)
  505.     NfsState *nfsPtr;
  506.     NfsOpenFile *cwdFilePtr;
  507.     Fs_UserIDs *idPtr;
  508. {
  509.     static AUTH *oldAuth = (AUTH *)NULL;
  510.  
  511.     if (oldAuth != (AUTH *)NULL) {
  512.     AUTH_DESTROY(oldAuth);
  513.     oldAuth = (AUTH *)NULL;
  514.     }
  515.     if (cwdFilePtr != (NfsOpenFile *)NULL) {
  516.     nfsPtr->nfsClnt->cl_auth = cwdFilePtr->authPtr;
  517.     } else {
  518.     if (idPtr->numGroupIDs > NGRPS) {
  519.         /*
  520.          * Patch so xdr_auth_unix doesn't fail.
  521.          */
  522.         idPtr->numGroupIDs = NGRPS;
  523.     }
  524.     oldAuth = nfsPtr->nfsClnt->cl_auth = authunix_create(myhostname,
  525.         idPtr->user, idPtr->group[0], idPtr->numGroupIDs, idPtr->group);
  526.     }
  527. }
  528.  
  529. /*
  530.  *----------------------------------------------------------------------
  531.  *
  532.  * CheckPermissions --
  533.  *
  534.  *    Client side permission checking so we can make an open fail
  535.  *    if the permissions are not sufficient.  The NFS server lets
  536.  *    any lookup request succeed if the client has permission over
  537.  *    the search path, and then does more permission checking at
  538.  *    each I/O.  Accordingly, we have to do a little more work at open time.
  539.  * 
  540.  * Results:
  541.  *    SUCCESS or an error code.
  542.  *
  543.  * Side effects:
  544.  *    None.
  545.  *
  546.  *----------------------------------------------------------------------
  547.  */
  548. int
  549.     CheckPermissions(nfsAttrPtr, created, useFlags, idPtr, wantType)
  550.     register fattr *nfsAttrPtr;
  551.     int created;
  552.     register int useFlags;
  553.     register Fs_UserIDs *idPtr;
  554.     register int wantType;
  555. {
  556.     register int thisType = nfsToSpriteFileType[(int)nfsAttrPtr->type];
  557.     register int index;
  558.     register int permBits;
  559.     register int *groupPtr;
  560.     register int status;
  561.  
  562.     /*
  563.      * Make sure the file type matches.  FS_FILE means any type, otherwise
  564.      * it should match exactly.  We have to patch 'thisType' of
  565.      * SYMBOLIC_LINK to REMOTE_LINK because of a Sprite kernel bug
  566.      * where it asks for REMOTE_LINKS instead of symbolic links
  567.      * when implementing the readlink() system call.
  568.      */
  569.     if (wantType == FS_REMOTE_LINK) {
  570.     wantType = FS_SYMBOLIC_LINK;
  571.     }
  572.     if ((wantType != FS_FILE) && (wantType != thisType)) {
  573.     if (wantType == FS_DIRECTORY) {
  574.         return(FS_NOT_DIRECTORY);
  575.     } else {
  576.         return(FS_WRONG_TYPE);
  577.     }
  578.     }
  579.     /*
  580.      * Dis-allow execution of directories...
  581.      */
  582.     if ((wantType == FS_FILE) && (useFlags & FS_EXECUTE) &&
  583.     (thisType != FS_FILE)) {
  584.     return(FS_WRONG_TYPE);
  585.     }
  586.  
  587.     /* Removed check which disallowed execution of file across NFS */
  588.     /* since the kernel can now do it (without setuid or setgid) JMS */
  589.  
  590.     if (idPtr->user == 0) {
  591.     /*
  592.      * For normal files, only check for execute permission.  This
  593.      * prevents root from being able to execute ordinary files by
  594.      * accident.  However, root has complete access to directories.
  595.      */
  596.     if (thisType == FS_DIRECTORY) {
  597.         return(SUCCESS);
  598.     }
  599.     useFlags &= FS_EXECUTE;
  600.     }
  601.     /*
  602.      * Check read/write/exec permissions against one of the owner bits,
  603.      * the group bits, or the world bits.  'permBits' is set to
  604.      * be the corresponding bits from the attributes and then
  605.      * shifted over so the comparisions are against the WORLD bits.
  606.      */
  607.     if (idPtr->user == nfsAttrPtr->uid) {
  608.     /*
  609.      * Because NFS is stateless it can't do permission checking right.
  610.      * A direct quote:
  611.      * "the server's permission checking algorithm should allow the owner
  612.      * of a file to access it regardless of the permission setting"
  613.      *
  614.      * Thus we don't enforce any permission checking on the owner here
  615.      * if the file has just been created.
  616.      * This lets programs like "update" and "cp -p" that preserve
  617.      * permissions copy a read-only file.
  618.      */
  619.     if (!created) {
  620.         permBits = (nfsAttrPtr->mode >> 6) & 07;
  621.     } else {
  622.         permBits = 07;
  623.     }
  624.     } else {
  625.     for (index = idPtr->numGroupIDs, groupPtr = idPtr->group;
  626.          index > 0;
  627.          index--, groupPtr++) {
  628.         if (*groupPtr == nfsAttrPtr->gid) {
  629.         permBits = (nfsAttrPtr->mode >> 3) & 07;
  630.         goto havePermBits;
  631.         }
  632.     }
  633.     permBits = nfsAttrPtr->mode & 07;
  634.     }
  635. havePermBits:
  636.     if (((useFlags & FS_READ) && ((permBits & FS_WORLD_READ) == 0)) ||
  637.     ((useFlags & FS_WRITE) && ((permBits & FS_WORLD_WRITE) == 0)) ||
  638.     ((useFlags & FS_EXECUTE) && ((permBits & FS_WORLD_EXEC) == 0))) {
  639.     /*
  640.      * The file's permission don't include what is needed.
  641.      */
  642.     status = FS_NO_ACCESS;
  643.     } else {
  644.     status = SUCCESS;
  645.     }
  646.     return(status);
  647. }
  648.  
  649. /*
  650.  *----------------------------------------------------------------------
  651.  *
  652.  * NfsGetAttrPath --
  653.  *
  654.  *    Called to stat a file in the NFS system.
  655.  * 
  656.  * Results:
  657.  *    None.
  658.  *
  659.  * Side effects:
  660.  *    None.
  661.  *
  662.  *----------------------------------------------------------------------
  663.  */
  664. int
  665. NfsGetAttrPath(clientData, name, openArgsPtr, spriteAttrPtr, redirectInfoPtr)
  666.     ClientData clientData;            /* Ref. to NfsState */
  667.     char *name;                /* Pathname to open */
  668.     Fs_OpenArgs *openArgsPtr;        /* Bundled arguments */
  669.     Fs_Attributes *spriteAttrPtr;    /* Return - attributes of the file */
  670.     Fs_RedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  671. {
  672.     NfsState *nfsPtr = (NfsState *)clientData;
  673.     diropokres dirResults;
  674.     fattr *nfsAttrPtr = &dirResults.attributes;
  675.     NfsOpenFile *cwdFilePtr;
  676.     int status;
  677.  
  678.     cwdFilePtr = PrefixIDToHandle(openArgsPtr->prefixID);
  679.     status = NfsLookup(nfsPtr, cwdFilePtr, name, openArgsPtr->useFlags,
  680.             &dirResults, (diropargs *)NULL, redirectInfoPtr);
  681.  
  682.     if (status != NFS_OK) {
  683.     return(NfsStatusMap(status));
  684.     }
  685.     NfsToSpriteAttr(nfsAttrPtr, spriteAttrPtr);
  686.     return(0);
  687. }
  688.  
  689. /*
  690.  *----------------------------------------------------------------------
  691.  *
  692.  * NfsSetAttrPath --
  693.  *
  694.  *    Called to change attributes of a file in the NFS system.
  695.  * 
  696.  * Results:
  697.  *    None.
  698.  *
  699.  * Side effects:
  700.  *    None.
  701.  *
  702.  *----------------------------------------------------------------------
  703.  */
  704. int
  705. NfsSetAttrPath(clientData, name, openArgsPtr, flags, attrPtr, redirectInfoPtr)
  706.     ClientData clientData;        /* Ref. to NfsState */
  707.     char *name;            /* Pathname to open */
  708.     Fs_OpenArgs *openArgsPtr;    /* Bundled arguments */
  709.     int flags;            /* Specify which attributes to set */
  710.     Fs_Attributes *attrPtr;    /* New attributes of the file */
  711.     Fs_RedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  712. {
  713.     NfsState *nfsPtr = (NfsState *)clientData;
  714.     diropokres dirResults;
  715.     sattrargs sattrArgs;
  716.     attrstat attrStat;
  717.     NfsOpenFile *cwdFilePtr;
  718.     int status;
  719.  
  720.     cwdFilePtr = PrefixIDToHandle(openArgsPtr->prefixID);
  721.     status = NfsLookup(nfsPtr, cwdFilePtr, name, openArgsPtr->useFlags,
  722.             &dirResults, (diropargs **)NULL, redirectInfoPtr);
  723.  
  724.     if (status != NFS_OK) {
  725.     return(NfsStatusMap(status));
  726.     }
  727.     bcopy((char *)&dirResults.file, (char *)&sattrArgs.file, sizeof(nfs_fh));
  728.     SpriteToNfsAttr(flags, attrPtr, &sattrArgs.attributes);
  729.     if (clnt_call(nfsPtr->nfsClnt, NFSPROC_SETATTR, xdr_sattrargs, &sattrArgs,
  730.         xdr_attrstat, &attrStat, nfsTimeout) != RPC_SUCCESS) {
  731.     clnt_perror(nfsPtr->nfsClnt, "NFSPROC_SETATTR");
  732.     return(FAILURE);
  733.     } else {
  734.     return(NfsStatusMap((int)attrStat.status));
  735.     }
  736. }
  737.  
  738. /*
  739.  *----------------------------------------------------------------------
  740.  *
  741.  * NfsMakeDevice --
  742.  *
  743.  *    Called to create a special file (device) in the NFS system.
  744.  *    This isn't supported by the NFS protocol.
  745.  * 
  746.  * Results:
  747.  *    None.
  748.  *
  749.  * Side effects:
  750.  *    None.
  751.  *
  752.  *----------------------------------------------------------------------
  753.  */
  754. int
  755. NfsMakeDevice(clientData, name, makeDevArgsPtr, redirectInfoPtr)
  756.     ClientData clientData;            /* Ref. to NfsState */
  757.     char *name;                /* Pathname to open */
  758.     Fs_MakeDeviceArgs *makeDevArgsPtr;    /* Bundled arguments */
  759.     Fs_RedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  760. {
  761.     return(FS_NO_ACCESS);
  762. }
  763.  
  764. /*
  765.  *----------------------------------------------------------------------
  766.  *
  767.  * NfsMakeDir --
  768.  *
  769.  *    Called to make a directory in the NFS system.
  770.  * 
  771.  * Results:
  772.  *    None.
  773.  *
  774.  * Side effects:
  775.  *    None.
  776.  *
  777.  *----------------------------------------------------------------------
  778.  */
  779. int
  780. NfsMakeDir(clientData, name, openArgsPtr, redirectInfoPtr)
  781.     ClientData clientData;        /* Ref. to NfsState */
  782.     char *name;            /* Pathname to open */
  783.     Fs_OpenArgs *openArgsPtr;    /* Bundled arguments */
  784.     Fs_RedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  785. {
  786.     NfsOpenFile *cwdFilePtr;
  787.     NfsState *nfsPtr = (NfsState *)clientData;
  788.     diropres longDirResults;
  789.     diropokres *dirResultsPtr = &longDirResults.diropres_u.diropres;
  790.     createargs createArgs;
  791.     diropargs *wherePtr = &createArgs.where;
  792.     register sattr *sattrPtr = &createArgs.attributes;
  793.     int status;
  794.     char component[NFS_MAXNAMLEN];
  795.  
  796.     wherePtr->name = component;
  797.     cwdFilePtr = PrefixIDToHandle(openArgsPtr->prefixID);
  798.     status = NfsLookup(nfsPtr, cwdFilePtr, name, openArgsPtr->useFlags,
  799.                dirResultsPtr, &wherePtr, redirectInfoPtr);
  800.     if (status == NFS_OK) {
  801.     return(EEXIST);
  802.     } else if (status == NFSERR_NOENT) {
  803.     sattrPtr->mode = openArgsPtr->permissions & 07777 | S_IFDIR;
  804.     sattrPtr->uid = openArgsPtr->id.user;
  805.     sattrPtr->gid = -1;
  806.     sattrPtr->size = 0;
  807.     sattrPtr->atime.seconds = -1;
  808.     sattrPtr->atime.useconds = -1;
  809.     sattrPtr->mtime.seconds = -1;
  810.     sattrPtr->mtime.useconds = -1;
  811.     if (clnt_call(nfsPtr->nfsClnt, NFSPROC_MKDIR, xdr_createargs,
  812.         &createArgs, xdr_diropres, &longDirResults, nfsTimeout)
  813.             != RPC_SUCCESS) {
  814.         clnt_perror(nfsPtr->nfsClnt, "NFSPROC_MKDIR");
  815.         return(FAILURE);
  816.     }
  817.     status = longDirResults.status;
  818.     }
  819.     return(NfsStatusMap(status));
  820. }
  821.  
  822. /*
  823.  *----------------------------------------------------------------------
  824.  *
  825.  * NfsRemove --
  826.  *
  827.  *    Called to remove a file from the NFS system.
  828.  * 
  829.  * Results:
  830.  *    None.
  831.  *
  832.  * Side effects:
  833.  *    None.
  834.  *
  835.  *----------------------------------------------------------------------
  836.  */
  837. int
  838. NfsRemove(clientData, name, lookupArgsPtr, redirectInfoPtr)
  839.     ClientData clientData;            /* Ref. to NfsState */
  840.     char *name;                /* Pathname to open */
  841.     Fs_LookupArgs *lookupArgsPtr;    /* Bundled arguments */
  842.     Fs_RedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  843. {
  844.     NfsOpenFile *cwdFilePtr;
  845.     NfsState *nfsPtr = (NfsState *)clientData;
  846.     diropokres dirResults;
  847.     diropargs dirOpArgs;
  848.     diropargs *wherePtr = &dirOpArgs;
  849.     nfsstat nfsStatus;
  850.     int status;
  851.     char component[NFS_MAXNAMLEN];
  852.  
  853.     wherePtr->name = component;
  854.     cwdFilePtr = PrefixIDToHandle(lookupArgsPtr->prefixID);
  855.     status = NfsLookup(nfsPtr, cwdFilePtr, name, lookupArgsPtr->useFlags,
  856.                &dirResults, &wherePtr, redirectInfoPtr);
  857.     if (status == NFS_OK) {
  858.     if (dirResults.attributes.type == NFDIR) {
  859.         return(FS_WRONG_TYPE);
  860.     }
  861.     if (clnt_call(nfsPtr->nfsClnt, NFSPROC_REMOVE, xdr_diropargs,
  862.         wherePtr, xdr_nfsstat, &nfsStatus, nfsTimeout)
  863.             != RPC_SUCCESS) {
  864.         clnt_perror(nfsPtr->nfsClnt, "NFSPROC_REMOVE");
  865.         return(FAILURE);
  866.     }
  867.     status = (int)nfsStatus;
  868.     }
  869.     return(NfsStatusMap(status));
  870. }
  871.  
  872. /*
  873.  *----------------------------------------------------------------------
  874.  *
  875.  * NfsRemoveDir --
  876.  *
  877.  *    Called to remove a directory from the NFS system.
  878.  * 
  879.  * Results:
  880.  *    None.
  881.  *
  882.  * Side effects:
  883.  *    None.
  884.  *
  885.  *----------------------------------------------------------------------
  886.  */
  887. int
  888. NfsRemoveDir(clientData, name, lookupArgsPtr, redirectInfoPtr)
  889.     ClientData clientData;            /* Ref. to NfsState */
  890.     char *name;                /* Pathname to open */
  891.     Fs_LookupArgs *lookupArgsPtr;    /* Bundled arguments */
  892.     Fs_RedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  893. {
  894.     NfsOpenFile *cwdFilePtr;
  895.     NfsState *nfsPtr = (NfsState *)clientData;
  896.     diropokres dirResults;
  897.     diropargs dirOpArgs;
  898.     diropargs *wherePtr = &dirOpArgs;
  899.     nfsstat nfsStatus;
  900.     int status;
  901.     char component[NFS_MAXNAMLEN];
  902.  
  903.     wherePtr->name = component;
  904.     cwdFilePtr = PrefixIDToHandle(lookupArgsPtr->prefixID);
  905.     status = NfsLookup(nfsPtr, cwdFilePtr, name, lookupArgsPtr->useFlags,
  906.                &dirResults, &wherePtr, redirectInfoPtr);
  907.     if (status == NFS_OK) {
  908.     if (dirResults.attributes.type != NFDIR) {
  909.         return(FS_NOT_DIRECTORY);
  910.     }
  911.     if (clnt_call(nfsPtr->nfsClnt, NFSPROC_RMDIR, xdr_diropargs,
  912.         wherePtr, xdr_nfsstat, &nfsStatus, nfsTimeout)
  913.             != RPC_SUCCESS) {
  914.         clnt_perror(nfsPtr->nfsClnt, "NFSPROC_RMDIR");
  915.         return(FAILURE);
  916.     }
  917.     status = (int)nfsStatus;
  918.     }
  919.     return(NfsStatusMap(status));
  920. }
  921.  
  922. /*
  923.  *----------------------------------------------------------------------
  924.  *
  925.  * NfsRename --
  926.  *
  927.  *    Called to rename a file in the NFS system.
  928.  * 
  929.  * Results:
  930.  *    None.
  931.  *
  932.  * Side effects:
  933.  *    None.
  934.  *
  935.  *----------------------------------------------------------------------
  936.  */
  937. int
  938. NfsRename(clientData, srcName, dstName, twoNameArgsPtr, redirect2InfoPtr)
  939.     ClientData clientData;            /* Ref. to NfsState */
  940.     char *srcName;            /* Original name */
  941.     char *dstName;            /* New name */
  942.     Fs_2PathParams *twoNameArgsPtr;    /* Lookup args plus prefixID2 */
  943.     Fs_2PathRedirectInfo *redirect2InfoPtr;/* Used when name leaves our domain */
  944. {
  945.     NfsOpenFile *cwdFilePtr;
  946.     NfsState *nfsPtr = (NfsState *)clientData;
  947.     diropokres dirResults;
  948.     renameargs rename;
  949.     diropargs *fromPtr = &rename.from;
  950.     diropargs *toPtr = &rename.to;
  951.     nfsstat nfsStatus;
  952.     int status;
  953.     char component[NFS_MAXNAMLEN];
  954.     char component2[NFS_MAXNAMLEN];
  955.     Fs_RedirectInfo redirectInfo;
  956.  
  957.     fromPtr->name = component;
  958.     cwdFilePtr = PrefixIDToHandle(twoNameArgsPtr->lookup.prefixID);
  959.     status = NfsLookup(nfsPtr, cwdFilePtr, srcName,
  960.         twoNameArgsPtr->lookup.useFlags,
  961.             &dirResults, &fromPtr, &redirectInfo);
  962.     if (status == EREMOTE) {
  963.     redirect2InfoPtr->name1ErrorP = 1;
  964.     redirect2InfoPtr->prefixLength = redirectInfo.prefixLength;
  965.     strcpy(redirect2InfoPtr->fileName, redirectInfo.fileName);
  966.     return(EREMOTE);
  967.     } else if (status == NFS_OK) {
  968.     if (twoNameArgsPtr->prefixID2.type == -1) {
  969.         redirect2InfoPtr->name1ErrorP = 0;
  970.         redirect2InfoPtr->prefixLength = 0;
  971.         redirect2InfoPtr->fileName[0] = '\0';
  972.         return(FS_CROSS_DOMAIN_OPERATION);
  973.     }
  974.     toPtr->name = component2;
  975.     cwdFilePtr = PrefixIDToHandle(twoNameArgsPtr->prefixID2);
  976.     status = NfsLookup(nfsPtr, cwdFilePtr, dstName,
  977.             twoNameArgsPtr->lookup.useFlags,
  978.             &dirResults, &toPtr, &redirectInfo);
  979.     if (clnt_call(nfsPtr->nfsClnt, NFSPROC_RENAME, xdr_renameargs,
  980.         &rename, xdr_nfsstat, &nfsStatus, nfsTimeout)
  981.             != RPC_SUCCESS) {
  982.         clnt_perror(nfsPtr->nfsClnt, "NFSPROC_RENAME");
  983.         return(FAILURE);
  984.     }
  985.     status = (int)nfsStatus;
  986.     }
  987.     return(NfsStatusMap(status));
  988. }
  989.  
  990. /*
  991.  *----------------------------------------------------------------------
  992.  *
  993.  * NfsHardLink --
  994.  *
  995.  *    Make a hard link between two files in the NFS system.
  996.  * 
  997.  * Results:
  998.  *    None.
  999.  *
  1000.  * Side effects:
  1001.  *    None.
  1002.  *
  1003.  *----------------------------------------------------------------------
  1004.  */
  1005. int
  1006. NfsHardLink(clientData, srcName, dstName, twoNameArgsPtr, redirect2InfoPtr)
  1007.     ClientData clientData;            /* Ref. to NfsState */
  1008.     char *srcName;            /* Original name */
  1009.     char *dstName;            /* New name */
  1010.     Fs_2PathParams *twoNameArgsPtr;    /* Lookup args plus prefixID2 */
  1011.     Fs_2PathRedirectInfo *redirect2InfoPtr;/* Used when name leaves our domain */
  1012. {
  1013.     NfsOpenFile *cwdFilePtr;
  1014.     NfsState *nfsPtr = (NfsState *)clientData;
  1015.     diropokres dirResults;
  1016.     linkargs link;
  1017.     diropargs *toPtr = &link.to;
  1018.     nfsstat nfsStatus;
  1019.     int status;
  1020.     char component[NFS_MAXNAMLEN];
  1021.     Fs_RedirectInfo redirectInfo;
  1022.  
  1023.     cwdFilePtr = PrefixIDToHandle(twoNameArgsPtr->lookup.prefixID);
  1024.     status = NfsLookup(nfsPtr, cwdFilePtr, srcName,
  1025.         twoNameArgsPtr->lookup.useFlags,
  1026.             &dirResults, (diropargs **)NULL, &redirectInfo);
  1027.     if (status == EREMOTE) {
  1028.     redirect2InfoPtr->name1ErrorP = 1;
  1029.     redirect2InfoPtr->prefixLength = redirectInfo.prefixLength;
  1030.     strcpy(redirect2InfoPtr->fileName, redirectInfo.fileName);
  1031.     return(EREMOTE);
  1032.     } else if (status == NFS_OK) {
  1033.     if (twoNameArgsPtr->prefixID2.type == -1) {
  1034.         redirect2InfoPtr->name1ErrorP = 0;
  1035.         redirect2InfoPtr->prefixLength = 0;
  1036.         redirect2InfoPtr->fileName[0] = '\0';
  1037.         return(FS_CROSS_DOMAIN_OPERATION);
  1038.     }
  1039.     bcopy((char *)&dirResults.file, (char *)&link.from, sizeof(nfs_fh));
  1040.     toPtr->name = component;
  1041.     cwdFilePtr = PrefixIDToHandle(twoNameArgsPtr->prefixID2);
  1042.     status = NfsLookup(nfsPtr, cwdFilePtr, dstName,
  1043.             twoNameArgsPtr->lookup.useFlags,
  1044.             &dirResults, &toPtr, &redirectInfo);
  1045.     if (clnt_call(nfsPtr->nfsClnt, NFSPROC_LINK, xdr_linkargs,
  1046.         &link, xdr_nfsstat, &nfsStatus, nfsTimeout)
  1047.             != RPC_SUCCESS) {
  1048.         clnt_perror(nfsPtr->nfsClnt, "NFSPROC_LINK");
  1049.         return(FAILURE);
  1050.     }
  1051.     status = (int)nfsStatus;
  1052.     }
  1053.     return(NfsStatusMap(status));
  1054. }
  1055.  
  1056.  
  1057. /*
  1058.  *----------------------------------------------------------------------
  1059.  *
  1060.  * NfsSymLink --
  1061.  *
  1062.  *    Called to make a symbolic link in the NFS system.
  1063.  * 
  1064.  * Results:
  1065.  *    None.
  1066.  *
  1067.  * Side effects:
  1068.  *    None.
  1069.  *
  1070.  *----------------------------------------------------------------------
  1071.  */
  1072. int
  1073. NfsSymLink(clientData, linkName, value, openArgsPtr, redirectInfoPtr)
  1074.     ClientData clientData;        /* Ref. to NfsState */
  1075.     char *linkName;            /* Original name */
  1076.     char *value;            /* New name */
  1077.     Fs_OpenArgs *openArgsPtr;        /* Open arguments */
  1078.     Fs_RedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  1079. {
  1080.     NfsOpenFile *cwdFilePtr;
  1081.     NfsState *nfsPtr = (NfsState *)clientData;
  1082.     diropokres dirResults;
  1083.     symlinkargs symLinkArgs;
  1084.     diropargs *wherePtr = &symLinkArgs.from;
  1085.     register sattr *sattrPtr = &symLinkArgs.attributes;
  1086.     nfsstat nfsStatus;
  1087.     int status;
  1088.     char component[NFS_MAXNAMLEN];
  1089.  
  1090.     symLinkArgs.to = value;
  1091.     wherePtr->name = component;
  1092.     cwdFilePtr = PrefixIDToHandle(openArgsPtr->prefixID);
  1093.     status = NfsLookup(nfsPtr, cwdFilePtr, linkName,
  1094.         openArgsPtr->useFlags,
  1095.             &dirResults, &wherePtr, redirectInfoPtr);
  1096.     if (status == NFS_OK) {
  1097.     return(EEXIST);
  1098.     } else if (status == NFSERR_NOENT) {
  1099.     sattrPtr->mode = openArgsPtr->permissions & 07777 | S_IFLNK;
  1100.     sattrPtr->uid = openArgsPtr->id.user;
  1101.     sattrPtr->gid = -1;
  1102.     sattrPtr->size = strlen(value);
  1103.     sattrPtr->atime.seconds = -1;
  1104.     sattrPtr->atime.useconds = -1;
  1105.     sattrPtr->mtime.seconds = -1;
  1106.     sattrPtr->mtime.useconds = -1;
  1107.     if (clnt_call(nfsPtr->nfsClnt, NFSPROC_SYMLINK, xdr_symlinkargs,
  1108.         &symLinkArgs, xdr_nfsstat, &nfsStatus, nfsTimeout)
  1109.             != RPC_SUCCESS) {
  1110.         clnt_perror(nfsPtr->nfsClnt, "NFSPROC_MKDIR");
  1111.         return(FAILURE);
  1112.     }
  1113.     status = (int)nfsStatus;
  1114.     }
  1115.     return(status);
  1116. }
  1117.  
  1118.  
  1119. /*
  1120.  *----------------------------------------------------------------------
  1121.  *
  1122.  * NfsDomainInfo --
  1123.  *
  1124.  *    Called to find out about an NFS file system.
  1125.  * 
  1126.  * Results:
  1127.  *    The number of blocks and the number of free blocks in the file system.
  1128.  *
  1129.  * Side effects:
  1130.  *    None.
  1131.  *
  1132.  *----------------------------------------------------------------------
  1133.  */
  1134. /*ARGSUSED*/
  1135. int
  1136. NfsDomainInfo(clientData, fileIDPtr, domainInfoPtr)
  1137.     ClientData clientData;        /* Ref. to NfsState */
  1138.     Fs_FileID *fileIDPtr;        /* Handle on top-level directory */
  1139.     Fs_DomainInfo *domainInfoPtr;    /* Return information */
  1140. {
  1141.     NfsState *nfsPtr = (NfsState *)clientData;
  1142.     statfsres fsStat;
  1143.  
  1144.     if (clnt_call(nfsPtr->nfsClnt, NFSPROC_STATFS, xdr_nfs_fh,
  1145.         nfsPtr->mountHandle, xdr_statfsres, &fsStat, nfsTimeout)
  1146.             != RPC_SUCCESS) {
  1147.     clnt_perror(nfsPtr->nfsClnt, "NFSPROC_STATFS");
  1148.     return(FAILURE);
  1149.     } else if (fsStat.status != NFS_OK) {
  1150.     return(fsStat.status);
  1151.     } else {
  1152.     domainInfoPtr->maxKbytes = fsStat.statfsres_u.reply.blocks *
  1153.                    fsStat.statfsres_u.reply.bsize / 1024;
  1154.     domainInfoPtr->freeKbytes = fsStat.statfsres_u.reply.bfree *
  1155.                    fsStat.statfsres_u.reply.bsize / 1024;
  1156.     domainInfoPtr->maxFileDesc = -1;
  1157.     domainInfoPtr->freeFileDesc = -1;
  1158.     domainInfoPtr->blockSize = fsStat.statfsres_u.reply.bsize;
  1159.     domainInfoPtr->optSize = fsStat.statfsres_u.reply.tsize;
  1160.     return(SUCCESS);
  1161.     }
  1162. }
  1163.  
  1164. /*
  1165.  *----------------------------------------------------------------------
  1166.  *
  1167.  * NfsHandlePrint --
  1168.  *
  1169.  *    Print out an NFS handle.
  1170.  * 
  1171.  * Results:
  1172.  *    None.
  1173.  *
  1174.  * Side effects:
  1175.  *    None.
  1176.  *
  1177.  *----------------------------------------------------------------------
  1178.  */
  1179. int
  1180. NfsHandlePrint(handlePtr)
  1181.     nfs_fh *handlePtr;
  1182. {
  1183.     register int i;
  1184.     register int *intPtr = (int *)handlePtr;
  1185.  
  1186.     printf("<");
  1187.     for (i=0 ; i<FHSIZE ; i += sizeof(int)) {
  1188.     printf("%x,", *intPtr);
  1189.     intPtr++;
  1190.     }
  1191.     printf(">");
  1192. }
  1193.  
  1194. @
  1195.  
  1196.  
  1197. 1.17
  1198. log
  1199. @Cleanup memory leaks.
  1200. @
  1201. text
  1202. @d18 1
  1203. a18 1
  1204. static char rcsid[] = "$Header: /sprite/src/cmds/nfsmount/RCS/nfsName.c,v 1.16 91/06/07 16:24:24 mottsmth Exp Locker: mottsmth $ SPRITE (Berkeley)";
  1205. a357 4
  1206.      if (Fs_IOControl(streamPtr->streamID, IOC_PDEV_WRITE_BEHIND,
  1207.          sizeof(int), &writeBehind, 0, NULL) != 0) {
  1208.         fprintf(stderr, "IOC_PDEV_WRITE_BEHIND failed\n");
  1209.      }
  1210. d359 4
  1211. @
  1212.  
  1213.  
  1214. 1.16
  1215. log
  1216. @Remove check that prevented execution of files across NFS
  1217. since the kernel can do it with two caveats:
  1218.     1) No setuid or setgid programs are allowed - security hole
  1219.     2) There's no code sharing. Should be though.
  1220. @
  1221. text
  1222. @d18 1
  1223. a18 1
  1224. static char rcsid[] = "$Header: /sprite/src/cmds/nfsmount/RCS/nfsName.c,v 1.15 91/03/23 19:20:08 mottsmth Exp Locker: mottsmth $ SPRITE (Berkeley)";
  1225. d386 5
  1226. a390 1
  1227.  *
  1228. d399 6
  1229. d414 1
  1230. a414 1
  1231.     nfsPtr->nfsClnt->cl_auth = authunix_create(myhostname,
  1232. @
  1233.  
  1234.  
  1235. 1.15
  1236. log
  1237. @(Sorry, small difficulties checking this *&%$^%@@ in.)
  1238. @
  1239. text
  1240. @d18 1
  1241. a18 1
  1242. static char rcsid[] = "$Header: /sprite/src/cmds/nfsmount/RCS/nfsName.c,v 1.12 90/01/25 17:19:32 brent Exp Locker: mottsmth $ SPRITE (Berkeley)";
  1243. d466 3
  1244. a468 6
  1245.     /*
  1246.      * Disallow execution of regular files too, until Sprite kernel is fixed.
  1247.      */
  1248.     if ((thisType != FS_DIRECTORY) && (useFlags & FS_EXECUTE)) {
  1249.     return(FS_NO_ACCESS);
  1250.     }
  1251. @
  1252.  
  1253.  
  1254. 1.14
  1255. log
  1256. @typo
  1257. @
  1258. text
  1259. @d18 1
  1260. a18 1
  1261. static char rcsid[] = "$Header: /sprite/src/cmds/nfsmount/RCS/nfsName.c,v 1.13 91/03/23 18:40:25 mottsmth Exp Locker: mottsmth $ SPRITE (Berkeley)";
  1262. d114 1
  1263. d121 1
  1264. a121 1
  1265.     if (!clnt_control(host, CLSET_RETRY_COUNT, -1)) {
  1266. @
  1267.  
  1268.  
  1269. 1.13
  1270. log
  1271. @Added support for retries after EIO on socket
  1272. (udp clients only)
  1273. @
  1274. text
  1275. @d18 1
  1276. a18 1
  1277. static char rcsid[] = "$Header: /sprite/src/cmds/nfsmount/RCS/nfsName.c,v 1.12 90/01/25 17:19:32 brent Exp Locker: mottsmth $ SPRITE (Berkeley)";
  1278. d120 1
  1279. a120 1
  1280.     if (!clnt_control(host, CL_SET_RETRY_COUNT, -1)) {
  1281. @
  1282.  
  1283.  
  1284. 1.12
  1285. log
  1286. @Fixed bug with numGroups > 8
  1287. @
  1288. text
  1289. @d18 1
  1290. a18 1
  1291. static char rcsid[] = "$Header: /a/newcmds/nfsmount/RCS/nfsName.c,v 1.11 89/10/10 13:17:19 douglis Exp $ SPRITE (Berkeley)";
  1292. d120 9
  1293. a128 5
  1294.     voidRes = nfsproc_null_2(&voidArg, clnt);
  1295.     if (voidRes == (VoidPtr)NULL) {
  1296.         clnt_perror(clnt, "nfsproc_null_2");
  1297.     } else if (pdev_Trace) {
  1298.         printf("Null RPC to NFS service at %s succeeded\n", host);
  1299. @
  1300.  
  1301.  
  1302. 1.11
  1303. log
  1304. @Changed void * to VoidPtr to remove lint
  1305. @
  1306. text
  1307. @d18 1
  1308. a18 1
  1309. static char rcsid[] = "$Header: /a/newcmds/nfsmount/RCS/nfsName.c,v 1.10 89/09/12 14:32:08 brent Exp Locker: douglis $ SPRITE (Berkeley)";
  1310. d212 1
  1311. a212 1
  1312.     int writeBehind = 0;
  1313. d311 8
  1314. a318 3
  1315.      (*nextFreeSlot)->authPtr = authunix_create(myhostname,
  1316.          openArgsPtr->id.user, openArgsPtr->id.group[0],
  1317.          openArgsPtr->id.numGroupIDs, openArgsPtr->id.group);
  1318. @
  1319.  
  1320.  
  1321. 1.10
  1322. log
  1323. @Patched NfsSetupAuth to handle numGroupIDs > NGRPS.
  1324. Updated to new Fs_ typedefs
  1325. @
  1326. text
  1327. @d18 1
  1328. a18 1
  1329. static char rcsid[] = "$Header: /a/newcmds/nfsmount/RCS/nfsName.c,v 1.9 89/06/30 10:29:31 brent Exp $ SPRITE (Berkeley)";
  1330. d112 2
  1331. a113 2
  1332.     void *voidArg;
  1333.     void *voidRes;
  1334. d121 1
  1335. a121 1
  1336.     if (voidRes == (void *)NULL) {
  1337. d426 1
  1338. a426 1
  1339.     register int thisType = nfsToSpriteFileType[nfsAttrPtr->type];
  1340. d607 1
  1341. a607 1
  1342.     return(NfsStatusMap(attrStat.status));
  1343. @
  1344.  
  1345.  
  1346. 1.9
  1347. log
  1348. @Added openFlags to the open file state so append-mode writes can work.
  1349. @
  1350. text
  1351. @d18 1
  1352. a18 1
  1353. static char rcsid[] = "$Header: /a/newcmds/nfsmount/RCS/nfsName.c,v 1.8 89/06/16 08:50:54 brent Exp $ SPRITE (Berkeley)";
  1354. d199 2
  1355. a200 2
  1356.     register FsOpenArgs *openArgsPtr;    /* Bundled arguments */
  1357.     FsRedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  1358. d388 6
  1359. d541 1
  1360. a541 1
  1361.     FsOpenArgs *openArgsPtr;        /* Bundled arguments */
  1362. d543 1
  1363. a543 1
  1364.     FsRedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  1365. d581 1
  1366. a581 1
  1367.     FsOpenArgs *openArgsPtr;    /* Bundled arguments */
  1368. d584 1
  1369. a584 1
  1370.     FsRedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  1371. d631 2
  1372. a632 2
  1373.     FsMakeDeviceArgs *makeDevArgsPtr;    /* Bundled arguments */
  1374.     FsRedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  1375. d656 2
  1376. a657 2
  1377.     FsOpenArgs *openArgsPtr;    /* Bundled arguments */
  1378.     FsRedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  1379. d714 2
  1380. a715 2
  1381.     FsLookupArgs *lookupArgsPtr;    /* Bundled arguments */
  1382.     FsRedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  1383. d764 2
  1384. a765 2
  1385.     FsLookupArgs *lookupArgsPtr;    /* Bundled arguments */
  1386.     FsRedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  1387. d815 2
  1388. a816 2
  1389.     Fs2PathParams *twoNameArgsPtr;    /* Lookup args plus prefixID2 */
  1390.     Fs2PathRedirectInfo *redirect2InfoPtr;/* Used when name leaves our domain */
  1391. d828 1
  1392. a828 1
  1393.     FsRedirectInfo redirectInfo;
  1394. d883 2
  1395. a884 2
  1396.     Fs2PathParams *twoNameArgsPtr;    /* Lookup args plus prefixID2 */
  1397.     Fs2PathRedirectInfo *redirect2InfoPtr;/* Used when name leaves our domain */
  1398. d894 1
  1399. a894 1
  1400.     FsRedirectInfo redirectInfo;
  1401. d950 2
  1402. a951 2
  1403.     FsOpenArgs *openArgsPtr;        /* Open arguments */
  1404.     FsRedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  1405. @
  1406.  
  1407.  
  1408. 1.8
  1409. log
  1410. @Added NfsDomainInfo
  1411. @
  1412. text
  1413. @d18 1
  1414. a18 1
  1415. static char rcsid[] = "$Header: /a/newcmds/nfsmount/RCS/nfsName.c,v 1.7 89/05/31 15:22:27 brent Exp $ SPRITE (Berkeley)";
  1416. d314 1
  1417. d321 1
  1418. a321 2
  1419.       * it from the type of zero used for the fileID of our root.  That
  1420.       * fileID is defined for us by the Sprite kernel.
  1421. @
  1422.  
  1423.  
  1424. 1.7
  1425. log
  1426. @Made the request buffer > 16K and enabled write-behind.
  1427. @
  1428. text
  1429. @d18 1
  1430. a18 1
  1431. static char rcsid[] = "$Header: /a/newcmds/nfsmount/RCS/nfsName.c,v 1.6 89/02/02 16:35:29 brent Exp $ SPRITE (Berkeley)";
  1432. d85 1
  1433. d136 3
  1434. a138 1
  1435.  *    NFS system we have mounted.
  1436. d141 1
  1437. a141 1
  1438.  *    None.
  1439. d144 1
  1440. a144 1
  1441.  *    None.
  1442. d149 2
  1443. a150 1
  1444. NfsProbe(nfsPtr)
  1445. d152 2
  1446. a154 1
  1447.     attrstat *nfsAttrPtr;
  1448. d156 5
  1449. a160 3
  1450.     nfsAttrPtr = nfsproc_getattr_2(nfsPtr->mountHandle, nfsPtr->nfsClnt);
  1451.     if (nfsAttrPtr == (attrstat *)NULL) {
  1452.     clnt_perror(nfsPtr->nfsClnt, "nfsproc_getattr_2");
  1453. d162 3
  1454. a164 2
  1455.     printf("Get attributes returns status %d\n", nfsAttrPtr->status);
  1456.     } else {
  1457. d175 1
  1458. a175 1
  1459.     printf("\n");
  1460. d985 45
  1461. @
  1462.  
  1463.  
  1464. 1.6
  1465. log
  1466. @Fixed readlink()
  1467. @
  1468. text
  1469. @d18 1
  1470. a18 1
  1471. static char rcsid[] = "$Header: /a/newcmds/nfsmount/RCS/nfsName.c,v 1.5 89/02/02 15:04:30 brent Exp $ SPRITE (Berkeley)";
  1472. d204 1
  1473. d328 1
  1474. d331 3
  1475. a333 1
  1476.      streamPtr = Pfs_OpenConnection(nfsPtr->pfsToken, fileIDPtr, 0, 0, NULL,
  1477. d335 9
  1478. @
  1479.  
  1480.  
  1481. 1.5
  1482. log
  1483. @Updated to new pfs package.
  1484. @
  1485. text
  1486. @d18 1
  1487. a18 1
  1488. static char rcsid[] = "$Header: /a/newcmds/nfsmount/RCS/nfsName.c,v 1.4 89/01/19 10:11:21 brent Exp Locker: brent $ SPRITE (Berkeley)";
  1489. d203 1
  1490. d239 1
  1491. d250 1
  1492. a250 1
  1493.     status = CheckPermissions(&dirResultsPtr->attributes,
  1494. d318 10
  1495. a327 4
  1496.      if (dirResultsPtr->attributes.type == NFDIR) {
  1497.          fileIDPtr->type = TYPE_DIRECTORY;
  1498.      } else {
  1499.          fileIDPtr->type = TYPE_FILE;
  1500. d392 1
  1501. a392 1
  1502. CheckPermissions(nfsAttrPtr, useFlags, idPtr, wantType)
  1503. d394 1
  1504. d407 4
  1505. a410 1
  1506.      * it should match exactly.
  1507. d412 3
  1508. d454 16
  1509. a469 1
  1510.     permBits = (nfsAttrPtr->mode >> 6) & 07;
  1511. @
  1512.  
  1513.  
  1514. 1.4
  1515. log
  1516. @Disallowing execution pending Sprite kernel fix
  1517. @
  1518. text
  1519. @d18 1
  1520. a18 1
  1521. static char rcsid[] = "$Header: /a/newcmds/nfssrv/RCS/nfsName.c,v 1.3 88/11/14 15:14:54 brent Exp $ SPRITE (Berkeley)";
  1522. d74 1
  1523. a74 10
  1524. IntProc nfsNameService[] = {
  1525.     NULL,             /* PDEV_INVALID */
  1526.     NULL,             /* PDEV_OPEN - only for pseudo-devices */
  1527.     NULL,            /* PDEV_DUP  - obsolete */
  1528.     BadProc,             /* PDEV_CLOSE */
  1529.     BadProc,            /* PDEV_READ */
  1530.     BadProc,            /* PDEV_WRITE */
  1531.     BadProc,            /* PDEV_IOCTL */
  1532.     BadProc,            /* PDEV_GET_ATTR - called on open pfs streams */
  1533.     BadProc,            /* PDEV_SET_ATTR - called on open pfs streams */
  1534. d84 1
  1535. a112 1
  1536.     extern int pdevTrace;
  1537. d122 1
  1538. a122 1
  1539.     } else if (pdevTrace) {
  1540. d187 3
  1541. a189 3
  1542. ReturnStatus
  1543. NfsOpen(private, name, openArgsPtr, pfsToken, redirectInfoPtr)
  1544.     ClientData private;            /* Ref. to NfsState */
  1545. a191 1
  1546.     ClientData pfsToken;        /* Needed for Pfs_OpenConnection */
  1547. d194 1
  1548. a194 1
  1549.     NfsState *nfsPtr = (NfsState *)private;
  1550. d196 1
  1551. d209 1
  1552. a209 7
  1553.     if (status == EREMOTE) {
  1554.     /*
  1555.      * redirectInfo contains a new pathname that the Sprite kernel
  1556.      * has to handle.
  1557.      */
  1558.     return(FS_LOOKUP_REDIRECT);
  1559.     } else if (status == NFSERR_NOENT && wherePtr != (diropargs *)NULL &&
  1560. d321 7
  1561. a327 2
  1562.      status = Pfs_OpenConnection(pfsToken, fileIDPtr, nfsFileService,
  1563.              (ClientData)fileIDPtr);
  1564. d480 3
  1565. a482 3
  1566. ReturnStatus
  1567. NfsGetAttrPath(private, name, openArgsPtr, spriteAttrPtr, redirectInfoPtr)
  1568.     ClientData private;            /* Ref. to NfsState */
  1569. d488 1
  1570. a488 1
  1571.     NfsState *nfsPtr = (NfsState *)private;
  1572. d520 3
  1573. a522 3
  1574. ReturnStatus
  1575. NfsSetAttrPath(private, name, openArgsPtr, flags, attrPtr, redirectInfoPtr)
  1576.     ClientData private;        /* Ref. to NfsState */
  1577. d529 1
  1578. a529 1
  1579.     NfsState *nfsPtr = (NfsState *)private;
  1580. d570 3
  1581. a572 3
  1582. ReturnStatus
  1583. NfsMakeDevice(private, name, makeDevArgsPtr, redirectInfoPtr)
  1584.     ClientData private;            /* Ref. to NfsState */
  1585. d595 3
  1586. a597 3
  1587. ReturnStatus
  1588. NfsMakeDir(private, name, openArgsPtr, redirectInfoPtr)
  1589.     ClientData private;        /* Ref. to NfsState */
  1590. d603 1
  1591. a603 1
  1592.     NfsState *nfsPtr = (NfsState *)private;
  1593. d617 1
  1594. a617 1
  1595.     return(FS_FILE_EXISTS);
  1596. d653 3
  1597. a655 3
  1598. ReturnStatus
  1599. NfsRemove(private, name, lookupArgsPtr, redirectInfoPtr)
  1600.     ClientData private;            /* Ref. to NfsState */
  1601. d661 1
  1602. a661 1
  1603.     NfsState *nfsPtr = (NfsState *)private;
  1604. d703 3
  1605. a705 3
  1606. ReturnStatus
  1607. NfsRemoveDir(private, name, lookupArgsPtr, redirectInfoPtr)
  1608.     ClientData private;            /* Ref. to NfsState */
  1609. d711 1
  1610. a711 1
  1611.     NfsState *nfsPtr = (NfsState *)private;
  1612. d753 3
  1613. a755 3
  1614. ReturnStatus
  1615. NfsRename(private, srcName, dstName, twoNameArgsPtr, redirect2InfoPtr)
  1616.     ClientData private;            /* Ref. to NfsState */
  1617. d762 1
  1618. a762 1
  1619.     NfsState *nfsPtr = (NfsState *)private;
  1620. d782 1
  1621. a782 1
  1622.     return(FS_LOOKUP_REDIRECT);
  1623. d811 1
  1624. a811 1
  1625.  *    Called to remove a directory from the NFS system.
  1626. d821 3
  1627. a823 3
  1628. ReturnStatus
  1629. NfsHardLink(private, srcName, dstName, twoNameArgsPtr, redirect2InfoPtr)
  1630.     ClientData private;            /* Ref. to NfsState */
  1631. d830 1
  1632. a830 1
  1633.     NfsState *nfsPtr = (NfsState *)private;
  1634. d847 1
  1635. a847 1
  1636.     return(FS_LOOKUP_REDIRECT);
  1637. d876 62
  1638. d950 1
  1639. a950 1
  1640. ReturnStatus
  1641. @
  1642.  
  1643.  
  1644. 1.3
  1645. log
  1646. @Added user authentication
  1647. @
  1648. text
  1649. @d18 1
  1650. a18 1
  1651. static char rcsid[] = "$Header: /a/newcmds/nfssrv/RCS/nfsName.c,v 1.2 88/11/11 11:33:18 brent Exp $ SPRITE (Berkeley)";
  1652. d424 7
  1653. @
  1654.  
  1655.  
  1656. 1.2
  1657. log
  1658. @Stable complete version
  1659. @
  1660. text
  1661. @d18 1
  1662. a18 1
  1663. static char rcsid[] = "$Header: /sprite/users/brent/nfstest/RCS/nfsName.c,v 1.1 88/11/02 12:44:26 brent Exp $ SPRITE (Berkeley)";
  1664. d54 3
  1665. a56 3
  1666. nfs_fh **nfsHandleTable = (nfs_fh **)NULL;
  1667. nfs_fh **nextFreeSlot = (nfs_fh **)NULL;
  1668. int nfsHandleTableSize = 0;
  1669. d66 3
  1670. a68 2
  1671.     ( (prefixID.type == TYPE_ROOT) ? (nfs_fh *)NULL : \
  1672.                  nfsHandleTable[prefixID.minor] )
  1673. d95 2
  1674. d121 1
  1675. d131 1
  1676. a131 1
  1677.     } else {
  1678. d205 1
  1679. a205 1
  1680.     nfs_fh *cwdHandlePtr;
  1681. d214 3
  1682. a216 2
  1683.     cwdHandlePtr = PrefixIDToHandle(openArgsPtr->prefixID);
  1684.     status = NfsLookup(nfsPtr, cwdHandlePtr, name, openArgsPtr->useFlags,
  1685. d257 2
  1686. d260 2
  1687. a261 5
  1688.      * We've got a good handle on the NFS file.  Save it in an array
  1689.      * indexed by part of the Fs_FileID we'll give to the Sprite kernel
  1690.      * and to the pdev callback library.  This will let us get back to
  1691.      * the handle from prefixID's in open arguments, and from the client
  1692.      * data passed to us from the callback library.
  1693. d263 13
  1694. a275 3
  1695.     register Fs_FileID *fileIDPtr;
  1696.     register int full = 0;
  1697.     if (nfsHandleTable == (nfs_fh **)NULL) {
  1698. d279 4
  1699. a282 4
  1700.         nfsHandleTable = (nfs_fh **)malloc(64 * sizeof(nfs_fh *));
  1701.         bzero((char *)nfsHandleTable, 64 * sizeof(nfs_fh *));
  1702.         nextFreeSlot = &nfsHandleTable[0];
  1703.         nfsHandleTableSize = 64;
  1704. d284 1
  1705. a284 1
  1706.     while (*nextFreeSlot != (nfs_fh *)NULL) {
  1707. d286 1
  1708. a286 1
  1709.         if (nextFreeSlot >= &nfsHandleTable[nfsHandleTableSize]) {
  1710. d288 1
  1711. a288 1
  1712.             nextFreeSlot = &nfsHandleTable[0];
  1713. d294 11
  1714. a304 11
  1715.             register nfs_fh **newTable =
  1716.                 (nfs_fh **)malloc(nfsHandleTableSize * 2 *
  1717.                           sizeof(nfs_fh *));
  1718.             bcopy((char *)nfsHandleTable, (char *)newTable,
  1719.                 nfsHandleTableSize * sizeof(nfs_fh *));
  1720.             bzero((char *)&newTable[nfsHandleTableSize],
  1721.                 nfsHandleTableSize * sizeof(nfs_fh *));
  1722.             free((char *)nfsHandleTable);
  1723.             nfsHandleTable = newTable;
  1724.             nextFreeSlot = &nfsHandleTable[nfsHandleTableSize];
  1725.             nfsHandleTableSize *= 2;
  1726. a307 2
  1727.      *nextFreeSlot = (nfs_fh *)malloc(sizeof(nfs_fh));
  1728.      bcopy((char *)&dirResultsPtr->file, (char *)*nextFreeSlot, NFS_FHSIZE);
  1729. d309 10
  1730. d328 1
  1731. a328 1
  1732.      fileIDPtr->minor = nextFreeSlot - nfsHandleTable;
  1733. d345 126
  1734. d494 1
  1735. a494 1
  1736.     nfs_fh *cwdHandlePtr;
  1737. d497 2
  1738. a498 2
  1739.     cwdHandlePtr = PrefixIDToHandle(openArgsPtr->prefixID);
  1740.     status = NfsLookup(nfsPtr, cwdHandlePtr, name, openArgsPtr->useFlags,
  1741. d536 1
  1742. a536 1
  1743.     nfs_fh *cwdHandlePtr;
  1744. d539 2
  1745. a540 2
  1746.     cwdHandlePtr = PrefixIDToHandle(openArgsPtr->prefixID);
  1747.     status = NfsLookup(nfsPtr, cwdHandlePtr, name, openArgsPtr->useFlags,
  1748. d605 1
  1749. a605 1
  1750.     nfs_fh *cwdHandlePtr;
  1751. d616 2
  1752. a617 2
  1753.     cwdHandlePtr = PrefixIDToHandle(openArgsPtr->prefixID);
  1754.     status = NfsLookup(nfsPtr, cwdHandlePtr, name, openArgsPtr->useFlags,
  1755. d663 1
  1756. a663 1
  1757.     nfs_fh *cwdHandlePtr;
  1758. d673 2
  1759. a674 2
  1760.     cwdHandlePtr = PrefixIDToHandle(lookupArgsPtr->prefixID);
  1761.     status = NfsLookup(nfsPtr, cwdHandlePtr, name, lookupArgsPtr->useFlags,
  1762. d677 3
  1763. d713 1
  1764. a713 1
  1765.     nfs_fh *cwdHandlePtr;
  1766. d723 2
  1767. a724 2
  1768.     cwdHandlePtr = PrefixIDToHandle(lookupArgsPtr->prefixID);
  1769.     status = NfsLookup(nfsPtr, cwdHandlePtr, name, lookupArgsPtr->useFlags,
  1770. d727 3
  1771. d764 1
  1772. a764 1
  1773.     nfs_fh *cwdHandlePtr;
  1774. d777 2
  1775. a778 2
  1776.     cwdHandlePtr = PrefixIDToHandle(twoNameArgsPtr->lookup.prefixID);
  1777.     status = NfsLookup(nfsPtr, cwdHandlePtr, srcName,
  1778. d794 2
  1779. a795 2
  1780.     cwdHandlePtr = PrefixIDToHandle(twoNameArgsPtr->prefixID2);
  1781.     status = NfsLookup(nfsPtr, cwdHandlePtr, dstName,
  1782. d832 1
  1783. a832 1
  1784.     nfs_fh *cwdHandlePtr;
  1785. d842 2
  1786. a843 2
  1787.     cwdHandlePtr = PrefixIDToHandle(twoNameArgsPtr->lookup.prefixID);
  1788.     status = NfsLookup(nfsPtr, cwdHandlePtr, srcName,
  1789. d860 2
  1790. a861 2
  1791.     cwdHandlePtr = PrefixIDToHandle(twoNameArgsPtr->prefixID2);
  1792.     status = NfsLookup(nfsPtr, cwdHandlePtr, dstName,
  1793. @
  1794.  
  1795.  
  1796. 1.1
  1797. log
  1798. @Initial revision
  1799. @
  1800. text
  1801. @d18 1
  1802. a18 1
  1803. static char rcsid[] = "$Header: fsPfs.c,v 6.0 88/10/11 15:52:49 brent Exp $ SPRITE (Berkeley)";
  1804. d235 1
  1805. a235 1
  1806.     sattrPtr->gid = openArgsPtr->id.group[0];    /* might be wrong */
  1807. d415 1
  1808. d457 34
  1809. a490 1
  1810.     return(FS_NO_ACCESS);
  1811. d515 23
  1812. a537 1
  1813.     return(FS_NO_ACCESS);
  1814. d562 23
  1815. a584 1
  1816.     return(FS_NO_ACCESS);
  1817. d603 1
  1818. a603 1
  1819. NfsRename(private, srcName, dstName, lookupArgsPtr, redirectInfoPtr)
  1820. d607 2
  1821. a608 2
  1822.     FsLookupArgs *lookupArgsPtr;    /* Bundled arguments */
  1823.     FsRedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  1824. d610 43
  1825. a652 1
  1826.     return(FS_NO_ACCESS);
  1827. d671 1
  1828. a671 1
  1829. NfsHardLink(private, srcName, dstName, lookupArgsPtr, redirectInfoPtr)
  1830. d673 4
  1831. a676 4
  1832.     char *srcName;            /* Name to link to */
  1833.     char *dstName;            /* New link to create */
  1834.     FsLookupArgs *lookupArgsPtr;    /* Bundled arguments */
  1835.     FsRedirectInfo *redirectInfoPtr;    /* Used when name leaves our domain */
  1836. d678 41
  1837. a718 1
  1838.     return(FS_NO_ACCESS);
  1839. @
  1840.